#define _CRT_SECURE_NO_WARNINGS 
#include<stdio.h>
int main()
{
	int a = 0; int b = 0;
	scanf("%d %d", &a, &b);
	int k = (a > b ? b : a);
	int m = 0;
	while (1)
	{
		if (a% k == 0 && b % k == 0)
		{
			int m = 1;  
			break;
		}
		else
		{
			k = k--;
		}

	}
	if (m == 1)
		printf("%d\n", k);
	return 0;
}